package lab03.test11;

import java.sql.*;

/**
 * Created by 星月 on 2017/12/05.
 */
public class Test {
    public static void main(String[] args) {
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;
        String sql = "insert into t_users(id,username,password) vlaues(1 ,'admin','admin','192312312123')";
        try {
            //加载驱动程序
            Class.forName("com.mysql.jdbc.Driver");
            connection= DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/sctu",
                    "root",
                    "123456"
            );//alt+enter+第一个
            statement=connection.createStatement();
            statement.execute(sql);//执行
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            try {
                statement.close();
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
